package com.lms.nio.channel;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-05-07 08:07
 * @Description: ${Description}
 */
public class RandomAccessFile01 {
    public static void main(String[] args) throws IOException {
        RandomAccessFile randomAccessFile = new RandomAccessFile("W:\\学习笔记\\demo.txt", "rw");
        FileChannel channel = randomAccessFile.getChannel();

        MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0, 11);
        byte[] bytes = new byte[11];
        map.get(bytes);
        System.out.println(new String(bytes));



    }
}
